package org.jin.jinaicode.config;

import com.aliyun.oss.OSS;
import com.aliyun.oss.OSSClientBuilder;
import org.springframework.beans.factory.annotation.Value;
import org.springframework.context.annotation.Bean;
import org.springframework.context.annotation.Configuration;

@Configuration
public class OssConfig {
    @Value("${alibaba.cloud.oss.endpoint}")
    private String endpoint;

    @Value("${alibaba.cloud.oss.access-key}")
    private String accessKeyId;

    @Value("${alibaba.cloud.oss.secret-key}")
    private String accessKeySecret;

    @Value("${alibaba.cloud.oss.bucket-name}")
    private String bucketName;

    @Value("${alibaba.cloud.oss.file-host:upload}")
    private String fileHost;

    @Value("${alibaba.cloud.oss.expire-time:3600}")
    private Long expireTime;

    @Bean
    public OSS ossClient() {
        return new OSSClientBuilder().build(endpoint, accessKeyId, accessKeySecret);
    }

    public String getEndpoint() {
        return endpoint;
    }

    public String getAccessKeyId() {
        return accessKeyId;
    }

    public String getAccessKeySecret() {
        return accessKeySecret;
    }

    public String getBucketName() {
        return bucketName;
    }

    public String getFileHost() {
        return fileHost;
    }

    public Long getExpireTime() {
        return expireTime;
    }
}